package com.huashi.dealer.commonEntity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.huashi.dealer.core.handler.JsonStringTypeHandler;
import com.huashi.dealer.core.util.TimeUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 订单物流信息表
 */
@Data
@TableName("yoshop_order_express")
@Schema(description = "订单物流信息表")
public class OrderExpress {
    @TableId(value = "order_express_id", type = IdType.AUTO)
    @Schema(description = "快递发货id")
    private Integer orderExpressId;

    @TableField("order_id")
    @Schema(description = "订单id")
    private Integer orderId;

    @TableField(value = "goods_id", typeHandler = JsonStringTypeHandler.class)
    @Schema(description = "商品id（包括赠品商品id）")
    private String goodsId;

    @TableField(value = "goods_num", typeHandler = JsonStringTypeHandler.class)

    @Schema(description = "发货数量")
    private String goodsNum;

    @TableField("express_id")
    @Schema(description = "物流公司id")
    private Integer expressId;

    @TableField("express_company")
    @Schema(description = "物流公司")
    private String expressCompany;

    @TableField("express_no")
    @Schema(description = "物流单号")
    private String expressNo;

    @TableField("delivery_time")
    @Schema(description = "发货时间")
    private Long deliveryTime;

    @TableField(value = "images", typeHandler = JsonStringTypeHandler.class)
    @Schema(description = "图片")
    private String images;

    @TableField("receipt_status")
    @Schema(description = "状态：10待收货，20已收货")
    private Integer receiptStatus;

    @TableField("receipt_time")
    @Schema(description = "收货时间")
    private Long receiptTime;

    @TableField("wxapp_id")
    @Schema(description = "小程序id")
    private Integer wxappId;

    @TableField("create_time")
    @Schema(description = "创建时间")
    private Long createTime;

    @TableField("update_time")
    @Schema(description = "更新时间")
    private Long updateTime;

    @Schema(description = "创建时间")
    @TableField(exist = false)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTimeFormat;

    @Schema(description = "更新时间")
    @TableField(exist = false)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTimeFormat;

    @Schema(description = "发货时间")
    @TableField(exist = false)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime deliveryTimeFormat;
    @Schema(description = "收货时间")
    @TableField(exist = false)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime receiptTimeFormat;

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
        this.setCreateTimeFormat(TimeUtil.changeToLocalDateTime(createTime));
    }
    public void setUpdateTime(Long updateTime) {
        this.updateTime = updateTime;
        this.setUpdateTimeFormat(TimeUtil.changeToLocalDateTime(updateTime));
    }
    public void setDeliveryTime(Long deliveryTime) {
        this.deliveryTime = deliveryTime;
        this.setDeliveryTimeFormat(TimeUtil.changeToLocalDateTime(deliveryTime));
    }
    public void setReceiptTime(Long receiptTime) {
        this.receiptTime = receiptTime;
        this.setReceiptTimeFormat(TimeUtil.changeToLocalDateTime(receiptTime));
    }
}